package cc.shacocloud.luanniao.core.service.ai.doubao

import cc.shacocloud.luanniao.core.service.ai.AbstractAiModel
import com.volcengine.ark.runtime.service.ArkService

/**
 * 火山方舟的豆包大模型
 *
 *  https://www.volcengine.com/docs/82379/1319854
 * @author 思追(shaco)
 */
class DoubaoAiModel(
    val arkService: ArkService,
    endpointId: String,
    defaultChatOptions: DoubaoChatOptions,
) : AbstractAiModel(
    chatModel = DoubaoChatModel(arkService, endpointId, defaultChatOptions),
    embeddingModel = DoubaoEmbeddingModel(arkService, endpointId)
) {

    constructor(
        apiKey: String,
        baseUrl: String = "https://ark.cn-beijing.volces.com/api/v3/",
        endpointId: String,
        defaultChatOptions: DoubaoChatOptions,
    ) : this(
        ArkService.builder()
            .apiKey(apiKey)
            .baseUrl(baseUrl)
            .build(),
        endpointId,
        defaultChatOptions
    )

    override fun close() {
        super.close()
        arkService.shutdownExecutor()
    }

}